package logic;

import java.util.TimerTask;

import view.GameScreen;

public class GameLogic extends TimerTask
{

	private boolean reset = false;
	private boolean gameRunning = true;
	private GameScreen gameScreen;

	@Override
	public void run()
	{
		gameLoop();

	}

	public GameLogic(GameScreen gameScreen)
	{
		this.gameScreen = gameScreen;
	}

	public void gameLoop()
	{		
		long lastLoopTime = System.currentTimeMillis();
		while (gameRunning && !reset)
		{
			long delta = System.currentTimeMillis() - lastLoopTime;
			lastLoopTime = System.currentTimeMillis();
			
			gameScreen.movePlayerEntities(delta);
			gameScreen.drawPlayerEntities(delta);	
			gameScreen.handleCollisions();
			if(gameScreen.reset == true)
			{
				gameScreen.reset();
			}
		}
	}

	public void gameEnd()
	{

	}
}
